package com.milo.builder;


import com.milo.outxml.AlipayXmlOutMessage;

/**
 * 消息基础Bulider
 * @author milogenius
 * @date 2020/3/23 16:01
 *
 */
public abstract class BaseBuilder<BuilderType, ValueType> {

  /**接收方账号*/
  protected String toUserId;

  /**支付宝生活号appid*/
  protected String appId;

  @SuppressWarnings("unchecked")
  public BuilderType toUserId(String toUserId) {
    this.toUserId = toUserId;
    return (BuilderType) this;
  }

  @SuppressWarnings("unchecked")
  public BuilderType appId(String appId) {
    this.appId = appId;
    return (BuilderType) this;
  }

  public abstract ValueType build() throws Exception;

  public void setCommon(AlipayXmlOutMessage m) {
    m.setToUserId(this.toUserId);
    m.setAppId(this.appId);
    m.setCreateTime(System.currentTimeMillis() / 1000L);
  }

}
